package workbench.actors;

import box2D.dynamics.B2ContactImpulse;
import box2D.dynamics.B2ContactListener;
import box2D.dynamics.contacts.B2Contact;
import box2D.dynamics.contacts.B2ContactEdge;
import com.funkyfurrymonkey.world2d.Actor;
import openfl.events.EventDispatcher;
import openfl.events.Event;
/**
 * ...
 * @author ...
 */
class ContactListener extends B2ContactListener
{

	public var eventDispatcher:EventDispatcher;
	private var m_cActor:Actor;
	public function new(cAvatar:Actor) 
	{
		super();
		m_cActor = cAvatar;
		eventDispatcher = new EventDispatcher();
	}
	 
	 override public function beginContact(contact:B2Contact):Void 
	 {
		 super.beginContact(contact);
	
		 var cHitterData:Object2dData = 	contact.getFixtureA().getBody().getUserData();		 
		 var cHittedData:Object2dData = 	contact.getFixtureB().getBody().getUserData(); 
		 
         trace(cHitterData.name);
		if (cHitterData.name == "final" )
		{
			m_cActor.hits(cHitterData);
		}
			
		 
			
	 }
	 
	 override public function postSolve(contact:B2Contact, impulse:B2ContactImpulse):Void 
	 {
		 super.postSolve(contact, impulse);
	 }
}